Skip to main content

mergJSON

Type

library

Description

mergJSON is an external for encoding and decoding JSON.

This external has been implemented to encode/decode UTF8 JSON to a LiveCode array as quickly as possible. Currently externals can not work with multi-dimensional LiveCode arrays so the intention is it is used with two functions like this:

    function ArrayToJSON pArray,pForceRootType,pPretty
repeat for each key tKey in pArray
if pArray[tKey] is an array then
put \"}\"&ArrayToJSON(pArray[tKey]) into pArray[tKey]
end if
end repeat
return(mergJSONEncode(\"pArray\",pForceRootType,pPretty))
end ArrayToJSON

function JSONToArray pJSON

        local tArray,tKeys
repeat for each line tKey in mergJSONDecode(pJSON,\"tArray\")
put JSONToArray(tArray[tKey]) into tArray[tKey]
end repeat
return tArray
end JSONToArray
Thank you for your feedback!

Was this page helpful?